home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / COMMON / TOOLS / VB / UNSUPPRT / DANIM / SAMPLES / DA / VISUALBASIC / SHOWCASE / MSCUBES / MSCUBES.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1998-03-12  |  4.1 KB  |  93 lines

  1. VERSION 5.00
  2. Object = "{34F681D0-3640-11CF-9294-00AA00B8A733}#1.0#0"; "danim.dll"
  3. Begin VB.Form mscubes 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Mscubes"
  6.    ClientHeight    =   4080
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   8505
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   4080
  14.    ScaleWidth      =   8505
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin DirectAnimationCtl.DAViewerControlWindowed DAViewerControlWindowed 
  17.       Height          =   3855
  18.       Left            =   120
  19.       OleObjectBlob   =   "mscubes.frx":0000
  20.       TabIndex        =   0
  21.       Top             =   120
  22.       Width           =   8295
  23.    End
  24. Attribute VB_Name = "mscubes"
  25. Attribute VB_GlobalNameSpace = False
  26. Attribute VB_Creatable = False
  27. Attribute VB_PredeclaredId = True
  28. Attribute VB_Exposed = False
  29. ' Visual Basic verion of Mscubes
  30. Private Sub Form_Load()
  31.   Set changingRate = CreateObject("DirectAnimation.DANumber")
  32.     changingRate.Init DAStatics.Until(DANumber(0.2), LeftButtonDown, _
  33.       DAStatics.Until(DANumber(0), LeftButtonDown, changingRate))
  34.       
  35.   ' Set up relative paths for media imports.  Does not work in VB
  36.   ' debug.  Create executable.
  37.   Dim mediaBase, geoBase, imgBase, midiBase As String
  38.   mediaBase = CurDir + "\..\..\..\..\..\Media\"
  39.   geoBase = mediaBase + "geometry\"
  40.   imgBase = mediaBase + "image\"
  41.   midiBase = mediaBase + "midi\"
  42.   'Import the needed geometry & images & sound.
  43.   Set geo = ImportGeometry(geoBase + "cube.x")
  44.   Set importSnd = ImportSound(midiBase + "circus.mid")
  45.   Set backgroundSnd = importSnd.Sound.RepeatForever()
  46.   Dim IELogos(8)
  47.   Set IELogos(0) = ImportImage(imgBase + "clogo1.gif")
  48.   Set IELogos(1) = ImportImage(imgBase + "clogo2.gif")
  49.   Set IELogos(2) = ImportImage(imgBase + "clogo3.gif")
  50.   Set IELogos(3) = ImportImage(imgBase + "clogo4.gif")
  51.   Set IELogos(4) = ImportImage(imgBase + "clogo5.gif")
  52.   Set IELogos(5) = ImportImage(imgBase + "clogo6.gif")
  53.   Set IELogos(6) = ImportImage(imgBase + "clogo7.gif")
  54.   Set IELogos(7) = ImportImage(imgBase + "clogo8.gif")
  55.   Set IELogos(8) = ImportImage(imgBase + "clogo9.gif")
  56.   'Call the Movie(), which cycles through the IELogos images every second.
  57.   Set imageCube = Movie(IELogos)
  58.   'Set lights.
  59.   Set pLight = PointLight.Transform(Translate3(0, 0, 4))
  60.   Set dLight = DirectionalLight.Transform(Rotate3(YVector3, 0.5))
  61.   'Manipulate the geometry.
  62.   Set geo = geo.Transform(Scale3Uniform(0.5)).Texture(imageCube.MapToUnitSquare())
  63.   'Create the four cubes and set them to rotate.
  64.   Set srate = Mul(LocalTime, DANumber(9))
  65.   Set cube1 = geo.Transform(Compose3(Translate3(0, 0, 2), _
  66.     Rotate3Anim(Vector3(0, 1, 0), Mul(DANumber(0.04), srate))))
  67.   Set cube2 = geo.Transform(Compose3(Translate3(0, 0, -2), _
  68.     Rotate3Anim(Vector3(0, 1, 1), Mul(DANumber(0.03), srate))))
  69.   Set cube3 = geo.Transform(Compose3(Translate3(2, 0, 0), _
  70.     Rotate3Anim(Vector3(0, 0, 1), Mul(DANumber(0.02), srate))))
  71.   Set cube4 = geo.Transform(Compose3(Translate3(-2, 0, 0), _
  72.     Rotate3Anim(Vector3(1, 1, 1), Mul(DANumber(0.03), srate))))
  73.   'Do the final prep work on the model.
  74.   Set finalgeo = UnionGeometry(cube1, UnionGeometry(cube2, UnionGeometry(cube3, cube4)))
  75.   Set Camera = PerspectiveCamera(5.5, 4.5).Transform(Scale3(45, 45, 1))
  76.   'Make the complete image rotate.
  77.   Set finalgeo = finalgeo.Transform(Rotate3Anim(YVector3, Integral(changingRate)))
  78.   Set finalgeo = UnionGeometry(finalgeo, pLight)
  79.   'Render and display the image.
  80.   Set rendered_geo = finalgeo.Render(Camera)
  81.   DAViewerControlWindowed.UpdateInterval = 0.2
  82.   'Set the image.
  83.   DAViewerControlWindowed.Image = Overlay(rendered_geo, DAStatics.SolidColorImage(White))
  84.   'Set the sound.
  85.   DAViewerControlWindowed.Sound = backgroundSnd
  86.   'Start the animation.
  87.   DAViewerControlWindowed.Start
  88. End Sub
  89. Function Movie(IELogos)
  90.   Set movieArray = DAStatics.DAArray(IELogos)
  91.   Set Movie = movieArray.NthAnim(DAStatics.Mod(LocalTime, DANumber(9)))
  92. End Function
  93.